import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-11-20
 * Time: 9:41
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int j = 0;
        while (n != 0 && m != 0){
            int usedSize = 0;
            Set<Integer> set = new HashSet<>();
            Set<Set<Integer>> sets = new HashSet<>();
            for (int i = 0; i < m; i++){
                int s1 = in.nextInt();
                int s2 = in.nextInt();
                if (sets.isEmpty()){
                    set.add(s1);
                    set.add(s2);
                    sets.add(set);
                    usedSize += 2;
                }else{
                    for (Set<Integer> s: sets){
                        if (s.contains(s1)){
                            if (!s.contains(s2)){
                                usedSize++;
                            }
                            s.add(s2);
                        }else if (s.contains(s2)){
                            if (!s.contains(s1)){
                                usedSize++;
                            }
                            s.add(s1);
                        }else{
                            set.add(s1);
                            set.add(s2);
                            sets.add(set);
                            usedSize += 2;
                        }
                    }
                }
            }
            int ret = n - usedSize + sets.size();
            System.out.println("Case " + ++j + ": " + ret);
            n = in.nextInt();
            m = in.nextInt();
        }
    }
}
